import _ from 'lodash'
import { echartsStyle, constValue } from '@/config/echartsStyle'
export const chargeOption = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'line',
      lineStyle: {
        width: 2,
        color: '#4C71F9',
        opacity: 0.5,
      },
    },
  },
  backgroundColor: echartsStyle.backgroundColor,
  legend: echartsStyle.legend,
  grid: echartsStyle.grid,
  xAxis: _.assign({ type: 'category' }, echartsStyle.xAxisObj),
  yAxis: [
    _.assign(
      {
        type: 'value',
        show: true,
        min: 0,
      },
      echartsStyle.yAxisObj
    ),
  ],
  series: [
    _.assign(
      {
        name: '充电订单',
        type: 'line',
      },
      echartsStyle.seriesLineObj('#1455FD', '#7D9EF4')
    ),
    _.assign(
      {
        name: '微信小程序',
        type: 'bar',
      },
      echartsStyle.seriesBarObj('#62DCB8', '#62DCB8')
    ),
    _.assign(
      {
        name: '支付宝小程序',
        type: 'bar',
      },
      echartsStyle.seriesBarObj('#21C393', '#21C393')
    ),
    _.assign(
      {
        name: '电卡',
        type: 'bar',
      },
      echartsStyle.seriesBarObj('#32997B', '#32997B')
    ),
  ],
} //充电订单统计
export const orderOption = {
  tooltip: {
    formatter: function (params) {
      return (
        params.name +
        '<br>' +
        params.marker.replace(
          /\[object Object\]/,
          params.color.colorStops[0].color
        ) +
        params.seriesName +
        ':' +
        params.data
      )
    },
  },
  backgroundColor: echartsStyle.backgroundColor,
  legend: echartsStyle.legend,
  grid: echartsStyle.grid,
  xAxis: _.assign({ type: 'category' }, echartsStyle.xAxisObj),
  yAxis: [
    _.assign(
      {
        type: 'value',
        show: false,
        splitNumber: constValue.splitNumber,
        min: 0,
      },
      echartsStyle.yAxisObj
    ),
  ],
  series: [
    _.assign(
      {
        type: 'bar',
      },
      echartsStyle.seriesBarObj('#A3E083', '#48D3A9')
    ),
  ],
} //各省订单走势图
export const orderRatioOption = {
  backgroundColor: echartsStyle.backgroundColor,
  color: ['#E29144', '#CCDB38', '#21C393', '#147BE5'],
  tooltip: {
    trigger: 'item',
  },
  legend: _.assign(
    {
      textStyle: {
        fontSize: 14,
        fontFamily: '微软雅黑',
        color: '#4A4A4A',
      },
    },
    echartsStyle.legend
  ),
  series: [
    {
      type: 'pie',
      radius: ['40%', '90%'],
      // center: ['30%', '50%'],
      avoidLabelOverlap: false,
      itemStyle: {
        normal: {
          label: {
            show: true,
            position: 'inner',
            formatter: '{d}%',
            distance: 0.7, //这项是标识距离中心点的距离
            textStyle: {
              align: 'center',
              baseline: 'middle',
              fontFamily: '微软雅黑',
              fontSize: 16,
              color: 'white',
            },
          },
          labelLine: {
            show: false,
          },
          emphasis: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)',
          },
        },
      },
    },
  ],
} //各省订单走势图
